//
//  MKNewsViewController.swift
//  MOKOAnnounce
//
//  Created by 曹相召 on 2017/7/7.
//  Copyright © 2017年 cc.moko. All rights reserved.
//  消息页面

import UIKit

class MKNewsViewController: MKBaseViewController,UITableViewDelegate,UITableViewDataSource {

    var listView:UITableView!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.makeUI()
    }
    
    func makeUI() -> Void {
        
        self.titleBar =
            MKTitleBar().titleBar(title: "消息", leftStyle: .None, rightStyle: .None, barStyle: .Default)
        self.view.addSubview(self.titleBar!)
        
        self.listView = UITableView.init(frame: CGRect.init(x: 0, y: 64, width: ScreenWidth, height: ScreenHeight - 64), style: .grouped)
        self.listView.contentInset = UIEdgeInsetsMake(0, 0, 49, 0)
        self.listView.separatorStyle = .none
        self.listView.delegate = self as UITableViewDelegate
        self.listView.dataSource = self as UITableViewDataSource
        self.listView .register(MKNewsSystemCell.classForCoder(), forCellReuseIdentifier: "MKNewsSystemCell")
        self.listView .register(MKNewsChatLatelyCell.classForCoder(), forCellReuseIdentifier: "MKNewsChatLatelyCell")
        self.view.addSubview(self.listView)
    }
    func numberOfSections(in tableView: UITableView) -> Int {
        return 2
    }
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        if(section == 0){
           return 2
        }
        return 1
    }
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        if(indexPath.section == 0 && indexPath.row == 0){
            let cell = tableView.dequeueReusableCell(withIdentifier: "MKNewsSystemCell", for: indexPath) as! MKNewsSystemCell
            cell.config(icon: "newChat_systemNotification", count: 1, tip: "系统通知", lineHiden: false)
            return cell
        }else if(indexPath.section == 0 && indexPath.row == 1){
            let cell = tableView.dequeueReusableCell(withIdentifier: "MKNewsSystemCell", for: indexPath) as! MKNewsSystemCell
            cell.config(icon: "newChat_MoKorecommend", count: 199, tip: "美空推荐", lineHiden: true)
            return cell
        }
        else{
            let cell = tableView.dequeueReusableCell(withIdentifier: "MKNewsChatLatelyCell", for: indexPath) as! MKNewsChatLatelyCell
//            cell.config(icon: "newChat_MoKorecommend", count: 199, tip: "美空推荐", lineHiden: true)
            return cell
            
        }
        
    }
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        if(indexPath.section == 0){
            return 50
        }
        return 66
    }
    func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
        return 8
    }
    func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
        return 0.1
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }

}
